package com.maidou.qiantai.common.utils.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author maidou
 * @Date 2024/2/12 16:48
 */

public class StringUtil
{
    public static List<Long> tagSplit(String tag){
        List<Long> ids = new ArrayList<Long>();
        if (tag==null||"".equals(tag)) {
            return ids;
        }

        try {
            List<String> list = Arrays.asList(tag.split(","));
            List<Long> collect = list.stream().map(item -> {
                String s = item.replaceAll("\\s*", "");
                Long aLong = Long.valueOf(s);
                return aLong;
            }).collect(Collectors.toList());
            ids = collect;
//                    stream().map(Long::valueOf).collect(Collectors.toList());
        }catch (Exception e){
            return ids;
        }
        return ids;
    }

    public static List<String> stringValueSplit(String tag){
        List<String> ids = new ArrayList<String>();
        if (tag==null||"".equals(tag)) {
            return ids;
        }

        try {
            List<String> list = Arrays.asList(tag.split(","));
            return list;
        }catch (Exception e){
            return ids;
        }
    }

    public static boolean equals(String str1,String str2){
        if (str1==null||str2==null){
            return false;
        }
        if ("".equals(str1)||"".equals(str2)){
            return false;
        }
        return str1.equals(str2);
    }
}
